package Demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-07-11
 * Time: 21:51
 */
public class Person implements Cloneable{
    public int id;
    public Money m=new Money();
    public Person(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                '}';
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        //return super.clone();  浅拷贝
        Person tmp=(Person)super.clone();
        tmp.m=(Money)this.m.clone();
        return tmp;
    }
}
